<script>
	import {
		getAddress,
		getLocation,
		Translation
	} from '@/utils/getAddres.js';
	import {getriders} from '@/api/all.js';
	import store from './store';
	export default {
		// async onLaunch() {
		// 	try {
		// 		// const location = await getLocation();
		// 		// store.commit('setLocation', location);
		// 		// const address = await getAddress(location);
		// 		// store.commit('setAddress', address);
		// 		// const ugaddress = await Translation(address.pois[0].title);
		// 		// store.commit('setugAddress', ugaddress);
		// 	} catch (error) {
		// 		console.error('Error:', error);
		// 	}
		// },
		onLaunch() {
			let riderinfo=uni.getStorageSync('riderinfo')
			if (!riderinfo) { // 如果token不存在
					uni.showToast({
						title: '请先登录',
						icon: "none",
						mask: true,
						duration: 2000
					})
					uni.redirectTo({
						url:'/pages/main/login'
					})
				}else{
					if(JSON.parse(riderinfo).address){
						getriders({}).then((res)=>{
							if(res.code==200){
								let data=res.body.data;
								store.commit('setUserinfo', data);
								if(data.is_locked){
									uni.redirectTo({
										url:'/pages/main/audit?type=4'
									})
								}else{
									uni.redirectTo({
										url:'/pages/main/main'
									})
								}
							}
						})
						
					}else{
						uni.navigateTo({
							url:'/pages/main/enroll'
						})
					}
				}

		},
		onShow() {
			console.log('App Show');
		},
		onHide() {
			console.log('App Hide');
		},
		methods: {}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "@/uni_modules/uview-ui/index.scss";
	@import '@/static/css/font.css';

	page {
		background-color:$uni-bg-color;
	}
</style>